import { HttpStatus } from "@nestjs/common";
import { ApiBadRequestResponse, ApiOperation, ApiRequestTimeoutResponse } from "@nestjs/swagger";
import { CrudOptions } from "@nestjsx/crud";
import { Photo } from "libs/db/entity/photo.entity";
import { ErrorRes } from "../_filter/ErrorRes";
import { CreatePhotoDto } from "./dto/create-photo-.dto";
import { ReplacePhotoDto } from "./dto/updata-photo-.dto";

export const PhotoCrudOps: CrudOptions = {
  model: {
    type: Photo
  },
  query: {
     
    join: {
      metadata: {
          
      },
    },
    exclude:  ["updatedAt", "deleteAt"]
  },
  routes: {
    getManyBase: {
      interceptors: [],
      decorators: [
        ApiOperation({
          description: '功能说明',
          summary: '获取多个 照片',
        }),
        ApiBadRequestResponse({
          description: '**Error**: Bad Request --- 参考相关 DTO 参数说明',
          status: HttpStatus.BAD_REQUEST,
          schema: {
            type: 'BadRequersException',
            example: new ErrorRes('BadRequestException - 小心也可能是 str []',HttpStatus.BAD_REQUEST, '/photo')
          } //ErrorRes
          // schema: HttpErrorByCode(HttpStatus.BADPhotoREQUEST)
        }),
        ApiRequestTimeoutResponse({
          description: '请求超时',
          status: HttpStatus.REQUEST_TIMEOUT,
          schema: {
            type: 'RequestTimeoutException',
            example: new ErrorRes('RequestTimeoutException',HttpStatus.REQUEST_TIMEOUT, '/photo')
          }
        })
      ],
    },
    getOneBase: {
      interceptors: [],
      decorators: [],
    },
    createOneBase: {
      interceptors: [],
      decorators: [],
      returnShallow: true
    },
    createManyBase: {
      interceptors: [],
      decorators: [],
    },
    replaceOneBase: {
      interceptors: [],
      decorators: [],
      allowParamsOverride: true,
      returnShallow: true
    },
    updateOneBase: {
      interceptors: [],
      decorators: [],
      allowParamsOverride: true,
      returnShallow: true
    },
    deleteOneBase: {
      interceptors: [],
      decorators: [],
      returnDeleted: true
    },
  },
  dto: {
    create: CreatePhotoDto,
    replace: ReplacePhotoDto
  },
  serialize: {
    getMany: ReplacePhotoDto,
    get: ReplacePhotoDto,
    create: ReplacePhotoDto,
    createMany: ReplacePhotoDto,
    update: ReplacePhotoDto,
    replace: ReplacePhotoDto,
    delete: ReplacePhotoDto,
  }
}